import request from './request'
import qs from 'qs'

interface SendSMSType{
    phone:number
}

interface PhoneLoginType{
  phone:number,
  verifyCode:string,
  uuid?:string
}

// 请求发送短信的接口
export const SendSMSAPI = (params:SendSMSType) => request.post('/sendSMS', qs.stringify(params)) 

// 手机号登录的接口                                    
export const PhoneLoginAPI = (params:PhoneLoginType):Promise<ResLoginType> => request.post('/phoneRegin', qs.stringify(params))

// 微信扫码登录的接口
export const WeiXinLoginAPI = (params:unknown) => request.post('/wechatUsers/PCLogin', qs.stringify(params))

// 手机号绑定微信的接口
export const BindPhoneAPI = (params:unknown) => request.post('/wechatUsers/binding', qs.stringify(params))

// 获取用户信息的接口
export const UserProfilesAPI = () => request.get('/shop/userProfiles')

// 请求详情页的数据
export const GoodDetailsAPI = (id:number) => request.get(`/products/${id}`);

// 加入购物车的接口
export const addToCartAPI = (params:unknown) => request.post('/shop/carts/add', qs.stringify(params))

// 请求详情页的数据
export const GoodsSearchAIP = (params:unknown) => request.get('/products', { params })

// 请求购物车的数据
export const CartDataAPI = () => request.get('/shop/carts')

// 删除购物车的数据
export const deleteCartAPI = (id:number) =>
  request.get(`/shop/carts?productIds=${id}`);

// 推荐商品接口
export const JingpinAPI = () => request.get("/products/recommend");
// export const JingpinAPI = function () {
//     return request.get('/products/recommend')
// }

// 首页热门商品
export const HotAPI = function () {
  return request.get("/products/hot");
};

// 商品详细数据接口
export const GoodsInfoAPI = function (id:number) {
  return request.get("/products/" + id);
};
